from django.db import models
from django import forms
from django.forms import ModelForm
from django.core.files.storage import FileSystemStorage

fs = FileSystemStorage(location="../../files")

# Create your models here.
class AppModel(models.Model):
    
    firstname = models.CharField(max_length = 20)
    lastname = models.CharField(max_length = 20)
    email = models.EmailField()
    living_group = models.CharField(max_length=40)
    year = models.IntegerField(max_length=4)
    course = models.CharField(max_length=5)
    resume= models.FileField(upload_to = 'resumes',storage=fs)
    
    
    title = models.CharField(max_length=100)
    abstract = models.TextField()
    
    audio = models.FileField(upload_to = 'audio', storage=fs)
    sup = models.TextField(blank=True)
    
    datestamp = models.DateTimeField()
    
class UserRSVP(models.Model):
    firstname = models.CharField(max_length = 20)
    lastname = models.CharField(max_length = 20)
    guest_num = models.IntegerField()
    datestamp = models.DateTimeField()
    email = models.EmailField()
    
class AppForm(ModelForm):
    class Meta:
        model = AppModel 
        exclude = ('datestamp') 
        widgets= {'firstname': forms.TextInput(attrs={'placeholder': 'First name','size':'20', 'class':'inputText'}),
                  'lastname': forms.TextInput(attrs={'placeholder': 'Last name','size':'20', 'class':'inputText'}),
                  'email': forms.TextInput(attrs={'placeholder': 'MIT email address','size':'20', 'class':'inputText'}),
                  'living_group': forms.TextInput(attrs={'placeholder': 'FSILG/Dorm','size':'20', 'class':'inputText'}),
                  'year': forms.TextInput(attrs={'placeholder': 'Year','size':'20', 'class':'inputText'}),
                  'course': forms.TextInput(attrs={'placeholder': 'Course','size':'20', 'class':'inputText'}),
    
                  'title': forms.TextInput(attrs={'placeholder': 'Proposed talk title','size':'59', 'class':'inputText'}),
                  'abstract': forms.Textarea(attrs={'placeholder': 'Enter abstract','size':'20', 'class':'inputText'})}
        
class RSVPForm(ModelForm):
    class Meta:
        model = UserRSVP
        exclude=('datestamp')
        widgets= {'firstname': forms.TextInput(attrs={'placeholder': 'First name','size':'20', 'class':'inputText'}),
                  'lastname': forms.TextInput(attrs={'placeholder': 'Last name','size':'20', 'class':'inputText'}),
                  'email': forms.TextInput(attrs={'placeholder': 'Email address','size':'20', 'class':'inputText'}),
                  'guest_num': forms.TextInput(attrs={'placeholder': '#','size':'1', 'class':'inputText'})}

class LoginForm(forms.Form):
    username = forms.CharField(max_length=100,widget=forms.TextInput(attrs={'placeholder':'Enter Username','require':'True','label':'Username'}))
    password = forms.CharField(widget=forms.PasswordInput(render_value=False,attrs={'placeholder':'Enter Password','require':'True','label':'Password'}),max_length=100) 